<?php

declare(strict_types=1);

namespace App\Request;

use Hyperf\Validation\Request\FormRequest;

class PassportRequest extends FormRequest
{
    protected array $scenes = [
        'login' => ['username','password','key','code'],
    ];
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     */
    public function rules(): array
    {
        return [
            'username' => 'required|min:2|max:20',
            'key' => 'required',
            'code' => 'required',
            'password' => 'required|min:6|max:30',
        ];
    }

    /**
     * 获取已定义验证规则的错误消息
     */
    public function messages(): array
    {
        return [
            'username.required' => '账号不能为空',
            'username.min' => '账号格式不正确',
            'username.max' => '账号格式不正确',
            'key.required' => '验证码错误-1',
            'code.required' => '验证码错误-2',
            'password.required' => '密码不能为空',
            'password.min' => '密码格式不正确、最少6位字符',
            'password.max' => '密码格式不正确、最多30位字符',
        ];
    }
}